/**
 * created by haitao.yao @ Feb 22, 2011
 */
package com.googlecode.storage;

import java.util.Calendar;

/**
 * @author haitao-yao
 * 
 */
public class InnerClock {

	/**
	 * inner clock start time stamp,from 2011-1-1 00:00:00.000
	 */
	protected static final long START_TIMESTAMP;

	static {
		Calendar c = Calendar.getInstance();
		c.set(Calendar.YEAR, 2011);
		c.set(Calendar.MONTH, 1);
		c.set(Calendar.DAY_OF_MONTH, 1);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.MILLISECOND, 0);
		START_TIMESTAMP = c.getTimeInMillis() / 100;
	}

	/**
	 * get the optimized time stamp of the system
	 * 
	 * @return
	 */
	public static final int currentMilliseconds() {
		return (int) (System.currentTimeMillis() / 100 - START_TIMESTAMP) ;
	}
}
